package com.chentf.behavioral.strategyy_Factory_templateMethod_01.code;

import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 工厂
 */
public class MyFactory {

    private static Map<String, AbstractHandler> strategyMap = new HashMap<>();

    public static AbstractHandler getInvokeStrategy(String key){
        return strategyMap.get(key);
    }

    public static void register(String key, AbstractHandler handler){
        if(StringUtils.isEmpty(key) || ObjectUtils.isEmpty(handler)){
            return;
        }
        strategyMap.put(key, handler);
    }

}
